<?php
namespace app\admin\logic\mqlogic;

use app\admin\logic\ImportMoney;
use app\common\library\rabitmq\MqConsumerObject;
use FSLock\FSLock;
use think\exception\ValidateException;
use think\Log;

//处理导入众包费
class Consumer extends MqConsumerObject
{
    public function __construct(array $config)
    {

        parent::__construct($config);
    }

    //消费者处理类
    public function run($message)
    {
        $message = json_decode($message, true);
        $real_file = cdnurl($message['file']);
        $import = new ImportMoney();
        $where['file'] = $message['file'];
        $where['task_id'] = $message['task_id'];
        $fileRes['type'] = 1;
        $fileRes['msg'] = '文件正常导入';
        try {
            $import->import($real_file, $message['task_id']);
        } catch (ValidateException $e) {
            $fileRes['type'] = 2;
            $fileRes['msg'] = $e->getMessage();
        }
        $import->fileRes($fileRes, $where);
        return true;
    }

    public function __destruct()
    {
        parent::__destruct();

    }

}